package com.betterwood.dragon.core.exception;

import com.betterwood.dragon.core.common.StatusEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 异常基类
 * </p>
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BaseException extends RuntimeException {
	/**
	 *
	 */
	private static final long serialVersionUID = 3937025695716408113L;
	private Integer code;
	private String message;
	private Object data;

	public BaseException(String message) {
		super(message);
		this.code = StatusEnum.ERROR.getCode();
		this.message = message;
	}

	public BaseException(StatusEnum statusEnum) {
		super(statusEnum.getMessage());
		this.code = statusEnum.getCode();
		this.message = statusEnum.getMessage();
	}

	public BaseException(StatusEnum statusEnum, Object data) {
		this(statusEnum);
		this.data = data;
	}

	public BaseException(Integer code, String message) {
		super(message);
		this.code = code;
		this.message = message;
	}

	public BaseException(Integer code, String message, Object data) {
		this(code, message);
		this.data = data;
	}
}
